package com.itheima.wms.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.wms.mapper.WareHouseMapper;
import com.itheima.wms.pojo.PageWareHouse;
import com.itheima.wms.pojo.WmsArea;
import com.itheima.wms.service.WareHouseService;
import com.itheima.wms.utils.PageBean;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class WareHouseServiceImpl implements WareHouseService {
    private final WareHouseMapper wareHouseMapper;

    @Override
    public void addWareHouse(WmsArea wmsArea) {
        wareHouseMapper.addWareHouse(wmsArea);
    }

    @Override
    public PageBean<WmsArea> queryFactoryAll(PageWareHouse pageWareHouse) {
        PageHelper.startPage(pageWareHouse.getCurrent(), pageWareHouse.getSize());
        Page<WmsArea> wmsAreas = wareHouseMapper.queryFactoryAll(pageWareHouse);
        return new PageBean<>(wmsAreas,wmsAreas.getTotal(),wmsAreas.getPageSize());
    }

    @Override
    public WmsArea queryWareHouseById(Integer id) {
        WmsArea  wareHouse=wareHouseMapper.queryWareHouseById(id);
        return wareHouse;
    }

    @Override
    public void updateWareHouse(WmsArea wmsArea) {
        wareHouseMapper.updateWareHouse(wmsArea);
    }

    @Override
    public void deleteWareHouse(List<Long> ids) {
        wareHouseMapper.deleteWareHouse(ids);
    }
}
